package cc.uncarbon.module.appapi.service;


import cc.uncarbon.framework.core.context.UserContextHolder;
import cc.uncarbon.framework.core.exception.BusinessException;
import cc.uncarbon.module.appapi.mapper.UserCouponMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yanrumiao.entity.UserCouponEntity;
import com.yanrumiao.enumns.AppErrorEnum;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


import java.util.List;


/**
 * 数据表注释
 */
@RequiredArgsConstructor
@Service
@Slf4j
public class UserCouponService {

    private final UserCouponMapper userCouponMapper;


    public List<UserCouponEntity> getCouponByUserId() {

        Long userId = UserContextHolder.getUserId();
        if(userId==null){
            throw new BusinessException(AppErrorEnum.USER_ID_NO);
        }
        LambdaQueryWrapper<UserCouponEntity> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(UserCouponEntity::getUserId, userId);

        List<UserCouponEntity> list = userCouponMapper.selectList(queryWrapper);
        return list;

    }
}
